//
//  CustonCollectionViewCell.m
//  MemoryTravel
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 fcx. All rights reserved.
//

#import "CustonCollectionViewCell.h"

@implementation CustonCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews{
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.layer.masksToBounds = YES;
    self.button.backgroundColor = [UIColor colorWithRed:65 / 255.0 green:176 / 255.0 blue:194 / 255.0 alpha:1.0];
    self.button.layer.cornerRadius = 15;
    self.button.layer.borderWidth = 1;
    self.button.layer.borderColor = [UIColor whiteColor].CGColor;
    [self.button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.button.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.button];
    
    [self.button mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 10, 0, 10));
    }];
}

- (void)buttonAction:(UIButton *)button{
    [self.customCollectionViewCellDelegate addressPass:self.city];
}

- (void)setCity:(NSString *)city{
    if (_city != city) {
        _city = city;
    }
    
    [self.button setTitle:city forState:UIControlStateNormal];
}

@end
